package logic

import (
	"context"
	"fmt"
	"good_srv/good"
	"good_srv/internal/svc"
	"good_srv/models"

	"github.com/zeromicro/go-zero/core/logx"
)

type RiderAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRiderAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RiderAddLogic {
	return &RiderAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 骑手订单展示
func (l *RiderAddLogic) RiderAdd(in *good.RiderAddRequest) (*good.RiderAddResponse, error) {
	// todo: add your logic here and delete this line
	var err error
	riders := models.Rider{
		Name:    in.Name,
		Soles:   in.Soles,
		OrderId: in.OrderId,
		Status:  in.Status,
	}
	if err = riders.RiderAdd(); err != nil {
		logx.Error("骑手订单添加失败")
		return nil, fmt.Errorf("骑手订单添加失败")
	}
	return &good.RiderAddResponse{
		Id: int64(riders.ID),
	}, nil
}
